# QDesktopWidget 桌面类

import sys
from PyQt5.QtWidgets import QMainWindow, QApplication,QDesktopWidget
from PyQt5.QtGui import QIcon  # 图标类


class MainWins(QMainWindow):

    def __init__(self, parent=None):
        super(MainWins, self).__init__(parent)
        # 设置主窗口标题
        self.setWindowTitle('第一个主窗口应用')

        # 设置窗口的尺寸
        self.resize(400, 300)
        self.SetCenter()
        # 获取状态栏
        self.status = self.statusBar()

        self.status.showMessage('只存在5秒', 5000)

    def SetCenter(self):
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()

        newLeft = (screen.width()-size.width())/2
        newTop = (screen.height()-size.height())/2

        self.move(newLeft, newTop)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # app.setWindowIcon()
    main = MainWins()
    main.show()
    sys.exit(app.exec_())
